import { request } from "../utils/request"
import { IUserinfo } from "./types"

/*
 * @Author: Yang Zhang
 * @Date: 2021-12-07 00:56:08
 * @LastEditors: Yang Zhang
 * @LastEditTime: 2021-12-07 23:09:12
 * @Description: 
 */
const api = {
  userinfo: '/store/user/info',
  editOwn: '/store/user/editOwn',
  editEmail: '/store/user/updateEmail',
  updatePwd: '/store/user/updatePassword'
}

export const getUserinfo = () => {
  return request({
    url: api.userinfo,
    method: 'get'
  })
}


export const editOwninfo = (data: IUserinfo) => {
  return request({
    url: api.editOwn,
    method: 'put',
    formData: true,
    data
  })
}


interface IEmailupdate {
  email: string
  code: string
}
export const updateEmail = (data: IEmailupdate) => {
  return request({
    url: api.editEmail,
    method: 'post',
    formData: true,
    data
  })
}

export const updatePassword = (data: any) => {
  return request({
    url: api.updatePwd,
    method: 'post',
    formData: true,
    data: data
  })
}